package awesome.cpu.structure;

import awesome.cpu.utils.Mode;

public class RegisterB extends SequentialComponent {
	
	private static boolean outputDebug = false;

	public final static int KEY_REGB_IN = 1;
	private int mRegBIn;
	
	public final static int KEY_REGB_OUT = 2;
	private int mRegBOut;
	
	private final static RegisterB mInstance = new RegisterB();
	
	private RegisterB() {}
	
	public static RegisterB getInstance() {
		return mInstance;
	}
	
	@Override
	void onClockTick() {
		mRegBOut = mRegBIn;
		if (outputDebug && Mode.getDebugLevel() >= Mode.DEBUG_LEVEL_PRINT_ALL) {
			System.out.println("RegB: B = " + mRegBOut);
		}
	}

	@Override
	boolean setData(int keyInterface, int data) {
		switch (keyInterface) {
		case KEY_REGB_IN:
			mRegBIn = data;
			return true;
		}
		return false;
	}

	@Override
	int getData(int keyInterface) {
		switch (keyInterface) {
		case KEY_REGB_OUT:
			return mRegBOut;
		}
		return 0;
	}
}
